package com.gitee.elf.core.data

import com.google.gson.*
import java.lang.reflect.Type


class DataDouble(var value: Double) : Data {

    override fun getValue(): Any {
        return value
    }
    override fun toString(): String {
        return value.toString()
    }


    override fun clone(): DataDouble {
        return DataDouble(value)
    }

    @SerializerType(DataDouble::class)
    class Serializer : JsonSerializer<DataDouble>, JsonDeserializer<DataDouble> {
        override fun serialize(src: DataDouble?, typeOfSrc: Type?, context: JsonSerializationContext?): JsonElement {
            return JsonPrimitive(src!!.value)
        }

        override fun deserialize(json: JsonElement?, typeOfT: Type?, context: JsonDeserializationContext?): DataDouble {
            return DataDouble(json!!.asDouble)
        }


    }
}